package com.jiayou.Bullet;

import com.jiayou.tools.Constclass;

import java.awt.*;

public class Bullet1 extends Model {
    private int sw;
    public Bullet1(){}
    public Bullet1(int x, int y, int speed,int sw) {
        super(x, y, speed);
        this.sw = sw;
    }

    public void draw(Graphics graphics)
    {
        Color color = graphics.getColor();
        graphics.setColor(Color.white);
       switch (sw)
       {
           case Constclass.DOWN:
               y+=speed;
               graphics.fill3DRect(x+13,y+40,5,5,false);
               break;
           case Constclass.UP:
               y-=speed;
               graphics.fill3DRect(x+13,y,5,5,false);
               break;
           case Constclass.RIGHT:
               x+=speed;
               graphics.fill3DRect(x+40,y+13,5,5,false);
               break;
           case Constclass.LEFT:
               x-=speed;
               graphics.fill3DRect(x,y+13,5,5,false);
               break;
       }
        graphics.setColor(color);
    }


    @Override
    public Rectangle rec() {
        switch (sw)
        {
            case Constclass.DOWN:
                return new Rectangle((int)x+18,(int)y+40,(int)5,(int)5);
            case Constclass.UP:
                return new Rectangle(x+18,y,5,5);
            case Constclass.RIGHT:
                return new Rectangle(x+40,y+18,5,5);
            case Constclass.LEFT:
                return new Rectangle(x,y+18,5,5);
        }
        return null;
    }
}
